Detect C functions that can be declared with static linkage#7127
Detect C functions that can be declared with static linkage#7127danmar merged 2 commits intocppcheck-opensource:mainfrom
Conversation
|
clang-tidy has |
|
On Mon, Dec 23, 2024 at 12:45:45AM -0800, chrchr-github wrote:
clang-tidy has `misc-use-internal-linkage`: https://clang.llvm.org/extra/clang-tidy/checks/misc/use-internal-linkage.html
Not sure if we should attempt to duplicate that functionality.
Although, clang-tidy is less effective as it cannot detect functions
used in a single TU while it's prototype resides in a header file.
|
|
There is also the compiler warning |
|
There is also the reverse case to be detected - prototypes which do not have an implementation - see https://trac.cppcheck.net/ticket/10670. |
It makes sense to me I think we should have this. Please finish it. 👍
That does not warn when there is a prototype but the function is only used in 1 TU. |
54c8c8c to
8e5472e
Compare
|
The failing tests have been resolved by now. Anything else that needs to be addressed before this can be merged? |
|
all other members are initialized but not isC
Fixed
|
Currently limited to C as I assume the anonymous namespace should be favored for C++.
|
Rebased to resolve merge conflicts. |
|
It would be pretty easy to cover C++ as well by conditionally adding a sentence about anonymous namespaces. |
I agree. We probably want to suggest 'static' keyword for C code. But for C++ code we can suggest using either a 'static' keyword or anonymous namespace, I don't feel we need to favor a particular solution. |
|
Also needs an entry in releasenotes.txt |
Introduced in PR cppcheck-opensource#7127.
Introduced in PR cppcheck-opensource#7127.
Currently limited to C as I assume the anonymous namespace should be favored for C++.